$().ready(function() {
// 在键盘按下并释放及提交后验证提交表单
    $("#defaultForm").validate({
        rules: {
            name: {
                required: true,
                minlength: 6,
                maxlength: 12,
                remote: {
                    url: "validateName",     //后台处理程序
                    type: "post",               //数据发送方式
                    dataType: "json",           //接受数据格式
                    data: {                     //要传递的数据
                        name: function() {
                            return $("#name").val();
                        }
                    }
                }
            },
            password: {
                required: true,
                minlength: 6,
                maxlength: 12
            },
            phone: {
                required: true,
                minlength: 11,
                maxlength: 11,
                remote: {
                    url: "validatePhone",     //后台处理程序
                    type: "post",               //数据发送方式
                    dataType: "json",           //接受数据格式
                    data: {                     //要传递的数据
                        phone: function() {
                            return $("#phone").val();
                        }
                    }
                }
            }

        },
        messages: {
            name: {
                required: "请输入管理员名",
                minlength: "用户名长度不小于6",
                maxlength: "用户名长度不能超过12",
                remote: "这个名字已经被注册过了"
            },
            password: {
                required: "请输入密码",
                minlength: "密码长度不能小于6",
                maxlength: "密码长度不能大于12"
            },
            phone: {
                required: "请输入手机号",
                minlength: "手机号码的长度为11",
                maxlength: "手机号码的长度为11",
                remote: "号码已经被注册过了"
            }

        }
    })
});